import org.junit.Test;

import java.io.*;

public class TestFile {

    public static void main(String[] args) {
        File file = new File("D:\\test\\test.txt");

        System.out.println(file.isFile());
        System.out.println(file.exists());
        System.out.println(file.length());
        System.out.println(file.getAbsoluteFile());

    }
    //字节流输入
      @Test
    public void BufferTest() throws IOException {
        File file=new File("D:\\test\\test.txt");
  InputStream in=null;
  in=new BufferedInputStream(new FileInputStream(file));


  int b;
  while ( (b=in.read())!=-1){
      System.out.print(b+"-");

  }
  in.close();
    }

//高效字节流输出
@Test
public void TestBufferOut() throws IOException {
   File file=new File("D:\\test\\test.txt");
   OutputStream out=null;

   //创建高效的字节流的输出对象
   out=new BufferedOutputStream(new FileOutputStream(file,true));
   out.write(25);
    out.write(97);
    out.write(97);
    out.write(97);
    out.close();

}
    //普通的字节流输出
    @Test
    public void TestOut() throws IOException {
        File file=new File("D:\\test\\test.txt");
        OutputStream out=null;

        //创建普通的字节流的输出对象
        out=new FileOutputStream(file,true);
        out.write(97);
        out.write(97);
        out.write(97);
        out.write(97);
        out.close();

    }




}
